﻿namespace NativeWin32
{
    using System;
    using System.Runtime.InteropServices;
    using System.Text;

    internal static class DbgHelpApi
    {
        [DllImport("DbgHelp.dll", EntryPoint = "EnumDirTree", CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern bool Native_EnumDirTree(IntPtr hProcess, string RootPath, string InputPathName, [In, Out] StringBuilder OutputPathBuffer, EnumDirTreeProc Callback, IntPtr pInfo);
        [DllImport("DbgHelp.dll", EntryPoint = "ImageNtHeader", SetLastError = true)]
        public static extern IntPtr Native_ImageNtHeader(IntPtr ImageBase);
        [DllImport("DbgHelp.dll", EntryPoint = "SymCleanup", SetLastError = true)]
        public static extern bool Native_SymCleanup(IntPtr hProcess);
        [DllImport("DbgHelp.dll", EntryPoint = "SymEnumSymbols", SetLastError = true)]
        public static extern bool Native_SymEnumSymbols(IntPtr hProcess, ulong BaseOfDll, SymEnumSymbolsProc EnumSymbolsCallback, IntPtr UserContext);
        [DllImport("DbgHelp.dll", EntryPoint = "SymEnumTypes", SetLastError = true)]
        public static extern bool Native_SymEnumTypes(IntPtr hProcess, ulong BaseOfDll, SymEnumSymbolsProc EnumSymbolsCallback, IntPtr UserContext);
        [DllImport("DbgHelp.dll", EntryPoint = "SymEnumTypesByName", CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern bool Native_SymEnumTypesByName(IntPtr hProcess, ulong BaseOfDll, string mask, SymEnumSymbolsProc EnumSymbolsCallback, IntPtr UserContext);
        [DllImport("DbgHelp.dll", EntryPoint = "SymFromIndex", SetLastError = true)]
        public static extern bool Native_SymFromIndex(IntPtr hProcess, ulong BaseOfDll, uint Index, IntPtr Symbol);
        [DllImport("DbgHelp.dll", EntryPoint = "SymGetModuleInfo64", SetLastError = true)]
        public static extern bool Native_SymGetModuleInfo64(IntPtr hProcess, ulong dwAddr, [In, Out] HeaderDbghelp.IMAGEHLP_MODULE64 ModuleInfo);
        [DllImport("DbgHelp.dll", EntryPoint = "SymGetOptions")]
        public static extern uint Native_SymGetOptions();
        [DllImport("DbgHelp.dll", EntryPoint = "SymGetTypeInfo", CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern bool Native_SymGetTypeInfo(IntPtr hProcess, ulong BaseOfDll, uint TypeId, [MarshalAs(UnmanagedType.U4)] HeaderDbghelp.IMAGEHLP_SYMBOL_TYPE_INFO GetType, IntPtr pInfo);
        [DllImport("DbgHelp.dll", EntryPoint = "SymInitialize", CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern bool Native_SymInitialize(IntPtr hProcess, string UserSearchPath, uint fInvadeProcess);
        [DllImport("DbgHelp.dll", EntryPoint = "SymLoadModule64", CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern ulong Native_SymLoadModule64(IntPtr hProcess, IntPtr hFile, string ImageName, string ModuleName, ulong BaseOfDll, uint SizeOfDll);
        [DllImport("DbgHelp.dll", EntryPoint = "SymSetOptions")]
        public static extern uint Native_SymSetOptions(uint SymOptions);
        [DllImport("DbgHelp.dll", EntryPoint = "SymSetSearchPath", CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern bool Native_SymSetSearchPath(IntPtr hProcess, string SearchPath);
        [DllImport("DbgHelp.dll", EntryPoint = "SymUnloadModule64", SetLastError = true)]
        public static extern bool Native_SymUnloadModule64(IntPtr hProcess, ulong BaseOfDll);
    }
}

